import 'package:fluttertoast/fluttertoast.dart';
import 'package:flutter/material.dart';

class HYToast {
  // 显示短时间的Toast
  static void showToast(String message) {
    HYToast.showShortToast(message);
  }

  // 显示短时间的Toast
  static void showShortToast(String message) {
    Fluttertoast.showToast(
      msg: message,
      toastLength: Toast.LENGTH_SHORT,
      gravity: ToastGravity.BOTTOM,
      timeInSecForIosWeb: 2,
      backgroundColor: Colors.black54,
      fontSize: 16.0,
    );
  }

  // 显示长时间的Toast
  static void showLongToast(String message) {
    Fluttertoast.showToast(
      msg: message,
      toastLength: Toast.LENGTH_LONG,
      gravity: ToastGravity.BOTTOM,
      timeInSecForIosWeb: 1,
      backgroundColor: Colors.black54,
      fontSize: 16.0,
    );
  }

  // 显示带有自定义位置的Toast
  static void showCustomToast(String message, ToastGravity gravity) {
    Fluttertoast.showToast(
      msg: message,
      toastLength: Toast.LENGTH_SHORT,
      gravity: gravity,
      timeInSecForIosWeb: 1,
      backgroundColor: Colors.black54,
      textColor: Colors.white,
      fontSize: 16.0,
    );
  }

  // 取消所有Toast
  static void cancelToast() {
    Fluttertoast.cancel();
  }
}
